<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //indexOf 方法返回给定元素在数组中第一次出现的位置，如果没有出现则返回-1
        var arr = ["a","b","c"];
        console.log(arr.indexOf("b"));// 1
        console.log(arr.indexOf("y"));// -1

        //indexOf 方法还可以接受第二个参数，表示搜索的开始位置
        var test = ["iwen","ime","itbaizhan","liu"];
        
        console.log(test.indexOf("liu",0));//3

        console.log(test.indexOf("ime",1));//1
        console.log(test.indexOf("ime",2));//-1
        console.log(test.indexOf("ime",3));//-1
        // console.log(test.indexOf("ime",4));
        
        
    </script>
</body>
</html>